package thinkinjava4.ch15_generics;

interface GenericGetter<T extends GenericGetter<T>> {
    T get();
}

interface Getter extends GenericGetter<Getter> {
}

public class GenericAndReturnTypes {
    void test(Getter g) {
        Getter result = g.get();
        GenericGetter gg = g.get();
    }

    public static void main(String[] args) {
        GenericAndReturnTypes types = new GenericAndReturnTypes();
        Getter getter = new Getter() {

            @Override
            public Getter get() {
                System.out.println("get()");
                return this;
            }
        };
        types.test(getter);
    }
}
